#导包
import requests

#定义一个类
class configHttp:
    def __init__(self,m,u,v,h):
        self.method = m
        self.interfaceUrl = u
        self.value = v
        self.header = h

    #定义对外方法
    def run(self):
        if self.method.lower() == "get":
            return self.__get()
        elif self.method.lower() == "post":
            return self.__post()

    def __get(self):
        re = requests.get(url=self.interfaceUrl,params=eval(self.value),headers=eval(self.header))
        return re

    def __post(self):
        re = requests.post(url=self.interfaceUrl,data=eval(self.value),headers=eval(self.header))
        return re



if __name__ == '__main__':
    method = "post"
    interfaceUrl = "https://wanandroid.com/user/login"
    value = {"username":"liangchao","password":123456}
    header = "{}"
    ch = configHttp(method,interfaceUrl,value,header)
    res = ch.run()
    print(res.text)



